package com.treeman.user;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
public class UserAdditionalInformations {

	@Column(name = "FIRST_NAME")
	private String firstName;

	@Column(name = "LAST_NAME")
	private String lastName;

	@Column(name = "BORN_DATE")
	private Date born;

	@Column(name = "AGE")
	private Integer age;

	@Column(name = "IMG_PATH")
	private String avatarImagePath;

	public UserAdditionalInformations() {
	}

	public UserAdditionalInformations(String firstName, String lastName,
			Date birthday, String avatarImagePath) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.born = birthday;

		Calendar now = Calendar.getInstance();
		Calendar born = Calendar.getInstance();

		now.setTime(new Date());
		born = Calendar.getInstance();
		Integer age = now.get(Calendar.YEAR) - born.get(Calendar.YEAR);
		if (now.get(Calendar.DAY_OF_YEAR) < born.get(Calendar.DAY_OF_YEAR)) {
			age -= 1;
		}
		this.age = age;

		this.avatarImagePath = avatarImagePath;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Date getBirthday() {
		return born;
	}

	public void setBirthday(Date birthday) {
		this.born = birthday;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getAvatarImagePath() {
		return avatarImagePath;
	}

	public void setAvatarImagePath(String avatarImagePath) {
		this.avatarImagePath = avatarImagePath;
	}
}
